import request from '@/utils/request.js'
import store from '@/store/index.js'
const headers = {
    "Content-Type": "multipart/form-data;binary",
};
const api={
    getList:(data)=>{//获取首页列表
        var url =""
        if (store.state.userinfo.roleType =='Salesman'){
            url ='/api/work/salesman/list';
            data.phone = store.state.userinfo.phone
        }
        else if (store.state.userinfo.roleType == 'Photographer' || store.state.userinfo.roleType == 'photographer'){
            url = '/api/work/Photographer/list';
        }
        else if (store.state.userinfo.roleType == 'UI'){
            url = '/api/work/ui/list';
        }
        console.log(store.state.userinfo.roleType)
        // data.phone = store.state.userinfo.phone
        return request({
            params:data,
            url,
            method:'GET'
        })
    },
    login: (data) => {//登录账户
        //暂无接口 测试
        // return new Promise((resolve,reject)=>{
        //   if(data.username=='admin'){
        //     resolve({
        //       code:200,
        //       data:{
        //         token:"Bearer fae171f5492411edb7a394c6917620ff"
        //       }
        //     })
        //   }
        //   else{
        //     reject({
        //       code:500,
        //       data:{
        //         message:'登录失败'
        //       }
        //     })
        //   }
        // })

        return request({
            data,
            url: '/admin/token',
            method: 'POST',
            // headers:{
            //   'Content-Type':'application/x-www-form-urlencoded'
            // },
            auth:{
              password:"dev123",
              username:"dev",
            }
        })
    },
    registor:data => { // 注册
        return request({
            data,
            url: '/admin/register',
            method: 'POST',
        })
    },
    getActivityList:params=>{//获取活动列表
      return request({
        params,
        url: '/api/events',
        method: 'GET'
      })
    },
    getOrderList:params=>{//获取订单列表
      return request({
        params,
        url: '/admin/order/list',
        method: 'GET'
      })
    },
    getServiceList:params=>{//获取服务列表
      return request({
        params,
        url: '/api/service/list',
        method: 'GET'
      })
    },
    getCouponList:params=>{//获取卡券列表
      return request({
        params,
        url: '/api/coupon/list',
        method: 'GET'
      })
    },
    getUserList:params=>{//获取用户列表
      return request({
        params,
        url: '/admin/user/ordinary/page',
        method: 'GET'
      })
    },
    getAadminList:params=>{//获取管理员列表
      return request({
        params,
        url: '/admin/user/page',
        method: 'GET'
      })
    },
    updateAadminState:params=>{//改变管理员状态
      return request({
        params,
        url: `/admin/user/status/${params.userId}/${params.status}`,
        method: 'POST'
      })
    },
    upload:data=>{//文件上传
        return request({
            data,
            url: '/admin/file/upload',
            method: 'POST',
            headers
        })
    },
    getScaleInfo:data => { // 获取返佣比例
      return request({
            url: '/admin/returnMoney/ratio',
            method: 'GET',
        })
    },
    setScale:data => { // 设置返佣比例
      return request({
            url: '/admin/returnMoney/set',
            method: 'POST',
            data
        })
    },
    getServiceInfo:data => { // 获取服务情况详情
      return request({
            url: '/admin/service/user',
            method: 'GET',
            params:data
        })
    },
    saveServiceInfo:data => { // 保存服务次数
      return request({
            url: '/admin/service/user/userService',
            method: 'PUT',
            data
        })
    }
}
export default api
